package com.gg.fmallspringboot.controller;



import com.gg.fmallspringboot.entity.UserAddr;
import com.gg.fmallspringboot.service.UserAddrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gg.fmallspringboot.model.Result;

@RestController
@RequestMapping("/useraddr")
public class UserAddrController {

    @Autowired
    private UserAddrService userAddrService;

    @GetMapping("/{userId}")
    public Result getALL(@PathVariable("userId") Integer userId){
        return userAddrService.getAllById(userId);
    }

    @GetMapping("/add")
    public Result addUserAddr(UserAddr userAddr) {
        return userAddrService.addUserAddr(userAddr);
    }

    @GetMapping("/update")
    public Result updateUserAddr(UserAddr userAddr){
        return userAddrService.updateUserAddr(userAddr);
    }
    @GetMapping("/delete")
    public Result deleteUserAddr(Integer addrId){
        return userAddrService.deleteUserAddr(addrId);
    }

    @GetMapping("/getone")
    public Result getOne(String addrId){
        return userAddrService.getOne(addrId);
    }

    @GetMapping("/getComAddr")
    public Result getComAddr(Integer userId){
        return userAddrService.getComAddr(userId);
    }
}


